//
// Created by xili on 2024/8/23 22:41.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    vector <vector<int>> mergeSimilarItems(vector <vector<int>> &items1, vector <vector<int>> &items2) {
        map<int, int> ump;
        for (auto &item: items1) {
            ump[item[0]] = item[1];
        }
        for (auto &item: items2) {
            ump[item[0]] += item[1];
        }
        vector <vector<int>> ans;
        for (auto &[x, y]: ump) {
            ans.push_back({x, y});
        }
        return ans;
    }
};